package com.zhengtoudai.ui.adapter;

import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zhengtoudai.R;
import com.zhengtoudai.ui.bean.AccountLog;
import com.zhengtoudai.view.recyclerview.RecyclerViewAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/8/29 0029.
 */

public class PopupRecycleAdapter extends RecyclerViewAdapter<PopupRecycleAdapter.ViewHolder, AccountLog.ResultEntity.TradeCode> {
    private int checkPosition=-1;

    public void setCheckPosition(int position){
        checkPosition=position;
        notifyDataSetChanged();
    }

    public int getCheckPosition(){
        return checkPosition;
    }
    @Override
    public PopupRecycleAdapter.ViewHolder mOnCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.popup_list_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void mOnBindViewHolder(PopupRecycleAdapter.ViewHolder holder, int position) {
        if (position==checkPosition){
            holder.mTvContent.setTextColor(ContextCompat.getColor(mContext,R.color.title_text));
        }else{
            holder.mTvContent.setTextColor(ContextCompat.getColor(mContext,R.color.black_3));
        }
        holder.mTvContent.setText(data.get(position).getValue());
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_content)
        TextView mTvContent;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
